package com.sky.rabc.enums;

public enum OrderStatus {
    UNPAID("unpaid","新订单"),
    REVIEW("review","待审核"),
    CONFIRMED("confirmed","订单确认"),
    PREPARING("preparing","备货中"),
    SHIPPED("shipped","发货中"),
    COMPLETED("completed","已完成"),
    REFUNDING("refunding","退款中"),
    REFUNDED("refunded","已退款"),
    CANCELLED("cancelled","取消订单"),
    CLOSED("closed","交易关闭");

    private String code;
    private String description;

    OrderStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PayType getOrderStatus(String code) {
        for (PayType payType : PayType.values()) {
            if (payType.getCode().equals(code)) {
                return payType;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}
